<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>网站后台管理模版</title>
		<link rel="stylesheet" type="text/css" href="../../static/admin/layui/css/layui.css" />
		<link rel="stylesheet" type="text/css" href="../../static/admin/css/admin.css" />
	</head>
	<body>
		<div class="wrap-container">
				<form class="layui-form" style="width: 90%;padding-top: 20px;">

                    <div class="layui-form-item">
                        <label class="layui-form-label">Id：</label>
                        <div class="layui-input-block">
                            <input type="text" name="label" required lay-verify="required" placeholder="请输入Id" autocomplete="off" class="layui-input deptId">
                        </div>
                    </div>
					<div class="layui-form-item">
						<label class="layui-form-label">名称：</label>
						<div class="layui-input-block">
							<input type="text" name="label" required lay-verify="required" placeholder="请输入名称" autocomplete="off" class="layui-input deptName">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">电话：</label>
						<div class="layui-input-block">
							<input type="text" name="label" required lay-verify="required" placeholder="请输入电话" autocomplete="off" class="layui-input deptTel"  >
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">邮箱：</label>
						<div class="layui-input-block">
							<input type="text" name="label" required lay-verify="required" placeholder="请输入邮箱" autocomplete="off" class="layui-input mail" >
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">地址：</label>
						<div class="layui-input-block">
							<input type="text" name="label" required lay-verify="required" placeholder="请输入地址" autocomplete="off" class="layui-input deptAddr" >
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-input-block">
							<button class="layui-btn layui-btn-normal addBtn" lay-submit lay-filter="formDemo" type="button">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
		</div>

		<script src="../../static/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script src="https://cdn.staticfile.org/jquery/2.0.0/jquery.min.js"></script>
		<script>
			$(".addBtn").click(function () {
				var deptId =$(".deptId").val();
				var deptName = $(".deptName").val();
				var deptTel =$(".deptTel").val();
				var email =$(".mail").val();
				var deptAddr =$(".deptAddr").val();

				$.ajax({
					async:true,
					url:"${pageContext.request.contextPath}/Dept/addDeptInfo",
					type:"POST",
					data:{
						deptName:deptName,
						deptTel:deptTel,
						email:email,
						deptAddr:deptAddr,
						deptId:deptId

					},
					dataType:"json",
					success:function(result,status,xhr){
						if(result == "1"){
							alert("添加成功");
						}else {
							alert("添加失败");
						}

					},
					error:function(xhr,status,error){
						alert("异步请求失败!");
					}
				});

			})



		</script>
	</body>

</html>